<template>
  <div class="allpage">
    <el-form :inline="true" :model="formInline" ref="formInline" class="form-style">
      <el-form-item label="供应商" prop="region" style="margin:15px 0 15px 30px">
        <el-select v-model="formInline.region" placeholder="全部">
          <el-option v-for="item in options" :key="item.SupplierId" :label="item.SupplierName" :value="item.SupplierId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="user" style="margin:15px 0 15px 30px">
         <el-date-picker
          type="date"
          v-model="formInline.user"
          @change="getSTime"
          placeholder="审核时间"
          value-format="yyyy-MM-dd"
        ></el-date-picker>
      </el-form-item>
      <el-form-item style="margin:15px 0 15px 30px">
        <el-button icon="el-icon-refresh" type="warning" @click="clean('formInline')">重置</el-button>
        <el-button icon="el-icon-search" type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form> 
    <div class="table-style">
    <el-table border :data="tableData" >
      <el-table-column prop="TrueName" label="供应商" width="180"></el-table-column>
      <el-table-column prop="AllPrice" label="提现金额" width="180"></el-table-column>
      <el-table-column prop="TakeTime" label="结算日期"></el-table-column>
      <el-table-column prop="IsCheckStr" label="状态">
        <template slot-scope="scope">
          <p v-show="scope.row.IsCheckStr==='已通过'" style="color:green">已通过</p>
          <p v-show="scope.row.IsCheckStr==='未审核'" style="color:red">待审核</p>
          <p v-show="scope.row.IsCheckStr==='online'" style="color:green">已通过(已线下转款)</p>
        </template>
      </el-table-column>
      <el-table-column prop="CheckTime" label="审核时间">
        <template slot-scope="scope">
              <p v-show="scope.row.CheckTime === ''">--</p>
              <p v-show="scope.row.CheckTime != ''">{{scope.row.CheckTime}}</p>
        </template>
      </el-table-column>
      <el-table-column prop label="操作" width="200">
        <template slot-scope="scope">
          <div v-if="scope.row.IsCheckStr==='未审核'">
            <el-button type="danger" size="mini" >审核</el-button>
            <el-button type="primary" size="mini" @click="goDePage(scope.$index,scope.row)">结算详情</el-button>
          </div>
          <div v-else>
            <el-button type="primary" size="mini" @click="goDePage(scope.$index,scope.row)">结算详情</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <botpage
      class="botpage-style"
      :currentPage="currentPage"
      :PageSize="PageSize"
      :total="total"
      @handleCurrentChange="currentChange"
      @handleSizeChange="pageSizeChange"
    />
    </div>
  </div>
</template>

<script>
import Botpage from "@/components/botpage/Botpage";
import { LoadWithdrawCheck, LoadSuppliers, Manage } from "@/request/api";
export default {
  data() {
    return {
      currentPage: 1,
      PageSize: 10,
      total: 1,
      options:[],
      formInline: {
        user: "",
        region: "",
      },
      tableData: [],
    };
  },
  methods: {
    //表格数据
    getTableData() {
      LoadWithdrawCheck({
        PageIndex: this.currentPage,
        PageSize: this.PageSize,
        OS: "PC",
        CustomerId: 1,
      }).then((res) => {
         if (res.StatusCode === 200) {
        this.tableData = res.Data;
        this.currentPage = res.PageIndexs;
        this.PageSize = res.PageCount;
        this.total = res.DataCounts;
        console.log(this.tableData)
        var that = this;
         for (let i in this.tableData) {
           that.tableData[i].CheckTime = this.tableData[i].CheckTime.replace(/(\/)/g,'-');
           console.log(that.tableData[i].CheckTime)
         }
         }
      });
    },
    //详情页
    goDePage(index,row) {
      let GMdepage = this.tableData[index]
      console.log(GMdepage)
      this.$router.push({
        path:"/gongdepage",
        query:{detail:this.tableData[index]}
      });
    },
    //select框
    getSelect() {
      LoadSuppliers()
        .then((res) => {
          this.options = res.Data;
          console.log(this.options)
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //查询
    onSubmit() {
      this.getTableData()
    },
    currentChange(event) {
      this.currentPage = event;
      this.getTableData();
    },
    pageSizeChange(event) {
      this.PageSize = event;
      this.getTableData();
    },
    //清空
    clean(formInline) {
      this.$refs[formInline].resetFields();
      this.getTableData()
    },
    //时间栏
    getSTime(val) {
      this.formInline.user = val;
    }
  },
  created() {
    this.getTableData();
    this.getSelect()
  },
  components: {
    Botpage,
  },
};
</script>

<style lang="less" scoped>
</style>